<template>
  <div id="app">
    <transition>
      <router-view />
    </transition>
    <van-tabbar v-model="active" fixed active-color="#07c160" v-show="tabbar">
      <van-tabbar-item icon="home-o" to="/">首页</van-tabbar-item>
      <van-tabbar-item icon="bars" to="/typepage">分类</van-tabbar-item>
      <van-tabbar-item icon="cart-o" to="/cart">购物车</van-tabbar-item>
      <van-tabbar-item icon="manager-o" to="/my">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: "app",
  // created() {
  //   this.$router.push({
  //     path:'/'
  //   })
  // },
  data() {
    return {
      active: 0,
      tabbar: true
    };
  },
  watch: {
    '$route.path': function (newval) {
      if (newval === '/') {
        this.active = 0;
      } else if (newval === '/typepage') {
        this.active = 1;
      } else if (newval === '/cart') {
        this.active = 2;
      } else if (newval === '/my') {
        this.active = 3;
      } else {
        this.active = null;
        // this.tabbar=false;
      }
    }
  }
};
</script>

<style lang="scss" >
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  // display: inline-block;
   background: #eeeeee;
   min-height: 660px;
}
// .v-enter {
//     opacity: 0;
//     transform: translateX(100%);
// }
// .v-leave-to {
//     opacity: 0;
//     transform: translateX(-100%);
//     position: absolute;
// }
// .v-enter-active,
// .v-leave-active {
//     transition: all 0.5s ease;
// }
</style>
